import argparse
import logging
from utils import process_file

def setup_logger():
    logging.basicConfig(
        filename=f'logs/run_{__import__("datetime").datetime.now().strftime("%Y%m%d")}.log',
        level=logging.INFO,
        format='%(asctime)s - %(levelname)s - %(message)s'
    )

def main():
    parser = argparse.ArgumentParser(description="关键词计数工具")
    parser.add_argument("filepath", help="文件路径，支持 .json 或 .csv")
    parser.add_argument("keyword", help="要查找的关键词")
    args = parser.parse_args()

    setup_logger()
    logging.info("程序启动")
    process_file(args.filepath, args.keyword)
    logging.info("程序结束")

if __name__ == "__main__":
    main()

# See PyCharm help at https://www.jetbrains.com/help/pycharm/
